'use strict'
const path = require('path')
function resolve(dir) {
  return path.join(__dirname, dir)
}
module.exports = {
  lintOnSave: false,
  devServer: {
    overlay: {
      warnings: false,
      errors: false
    },
    proxy: {
      '/main': {
        target: 'http://10.32.50.185:8778/api/public/main',
        changeOrigin: true,
        // logLevel: 'debug',
        pathRewrite: {
          '^/main': ''
        }
      },
      '/exception': {
        target: 'http://10.32.50.185:8778/api/public/exception',
        changeOrigin: true,
        // logLevel: 'debug',
        pathRewrite: {
          '^/exception': ''
        }
      },
      '/cloud': {
        target: 'http://www.hikparking.com:8086/cloud',
        changeOrigin: true,
        // logLevel: 'debug',
        pathRewrite: {
          '^/cloud': ''
        }
      }
    }
  },

  configureWebpack: {
    externals: {
      AMap: 'AMap' // 高德地图配置
    }
  },
  chainWebpack(config) {
    // set svg-sprite-loader
    config.module
      .rule('svg')
      .exclude.add(resolve('src/icons'))
      .end()
    config.module
      .rule('icons')
      .test(/\.svg$/)
      .include.add(resolve('src/icons'))
      .end()
      .use('svg-sprite-loader')
      .loader('svg-sprite-loader')
      .options({
        symbolId: 'icon-[name]'
      })
      .end()

    // set preserveWhitespace
    config.module
      .rule('vue')
      .use('vue-loader')
      .loader('vue-loader')
      .tap(options => {
        options.compilerOptions.preserveWhitespace = true
        return options
      })
      .end()
  }
}
